package com.football;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/** 
 * @date 2016年5月25日 上午8:27:20 
 */
public class Mainpage extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Mainpage(){
		Dimension d = new Dimension();
		d.setSize(300, 300);
		this.setSize(d);
		
		Point p = new Point();
		p.x = 100;
		p.y=50;
		this.setLocation(p);
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		ImageIcon background = new ImageIcon("22.jpg");
		JLabel label = new JLabel(background);
		
		Point p1 = new Point();
		p1.x=0;
		p1.y=0;
		label.setLocation(p1);
		
		Dimension d1 = new Dimension();
		d1.setSize(background.getIconWidth(), background.getIconHeight());
		label.setSize(d1);
		
		Container c = this.getContentPane();
		JPanel  imagePanel = (JPanel) c;
		imagePanel.setOpaque(true);//控件透明化
		imagePanel.setLayout(null);
		
		this.setLayout(null);
		this.add(label,-1);
		Dimension d2 = new Dimension();
		d2.setSize(background.getIconWidth(), background.getIconHeight());
		this.setSize(d2);
		
		JLabel titleLabel = new JLabel();
		titleLabel.setText("Welcome to our football system!");
		titleLabel.setForeground(Color.white);
		Font font = new Font("TimesRoman", Font.BOLD, 30);
		titleLabel.setFont(font);
		
		Point p3 = new Point();
		p3.x = 300;
		p3.y=30;
		titleLabel.setLocation(p3);
		Dimension d3 = new Dimension();
		d3.setSize(600, 30);
		titleLabel.setSize(d3);
		this.add(titleLabel,0);
		
		JButton dispBut = new JButton("Display Football Member");
		Point p4 = new Point();
		p4.x = 100;
		p4.y = 100;
		
		dispBut.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {

				new DispMemberFrame().setVisible(true);
				
			}
		});
		dispBut.setLocation(p4);
		Dimension d4 = new Dimension();
		d4.setSize(300, 30);
		dispBut.setSize(d4);
		this.add(dispBut, 0);
		
		JButton deletePlayerBut = new JButton("Delete a player");
		Point p5 = new Point();
		p5.x = 500;
		p5.y = 100;
		deletePlayerBut.setLocation(p5);
		Dimension d5 = new Dimension();
		d5.setSize(300, 30);
		deletePlayerBut.setSize(d5);
		this.add(deletePlayerBut, 0);
		deletePlayerBut.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {

				new DeletePlayerDialog();
				
			}
		});
		
		JButton leaveMsgBut = new JButton("Leave a message");
		Point p6 = new Point();
		p6.x = 100;
		p6.y = 150;
		leaveMsgBut.setLocation(p6);
		Dimension d6 = new Dimension();
		d6.setSize(300, 30);
		leaveMsgBut.setSize(d6);
		this.add(leaveMsgBut, 0);
		leaveMsgBut.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {

//				new LeaveMsgDialog();
				
			}
		});
		
		JButton showMsgBut = new JButton("Show all messages");
		Point p7 = new Point();
		p7.x = 500;
		p7.y = 150;
		showMsgBut.setLocation(p7);
		Dimension d7 = new Dimension();
		d7.setSize(300, 30);
		showMsgBut.setSize(d7);
		this.add(showMsgBut, 0);
		showMsgBut.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {

//				new LeaveMsgDialog();
				
			}
		});
		
		
		this.setVisible(true);
	}
	public static void main(String args[]){
		new Mainpage();
	}
}
